﻿<UserControl x:Class="Microsoft.Research.ScientificWorkflow.ManagementStudioControls.WorkflowManagerModule.WorkflowJobListView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:converters="clr-namespace:Microsoft.Research.ScientificWorkflow.ManagementStudioControls.WorkflowManagerModule"
    xmlns:Controls="clr-namespace:Microsoft.Research.ScientificWorkflow.UIDesigner;assembly=Microsoft.Research.ScientificWorkflow.UIDesigner">
    <UserControl.Resources>
        <ContextMenu x:Key="EmptyContextMenu"/>
        <BooleanToVisibilityConverter x:Key="VisibilityConverter"></BooleanToVisibilityConverter>
        <converters:DateTimeConverter x:Key="DateTimeConverter"></converters:DateTimeConverter>
        <DataTemplate x:Key="ProvenanceLink">
            <Grid Background="Transparent" Width="18.207" Height="13.264" ToolTip="Show Provenance" PreviewMouseDown="Grid_PreviewMouseDown" VerticalAlignment="Top">
                <Rectangle Margin="8.295,2.269,5.912,0" VerticalAlignment="Top" Height="4" Stroke="{x:Null}" StrokeThickness="1.5">
                    <Rectangle.Fill>
                        <LinearGradientBrush EndPoint="0.682,0.629" StartPoint="0.251,0.072">
                            <GradientStop Color="#FF8A3200" Offset="0"/>
                            <GradientStop Color="#FFFFA435" Offset="1"/>
                        </LinearGradientBrush>
                    </Rectangle.Fill>
                </Rectangle>
                <Rectangle Margin="8.295,0,5.912,0" VerticalAlignment="Bottom" Stroke="{x:Null}" StrokeThickness="1.5" Height="4">
                    <Rectangle.Fill>
                        <LinearGradientBrush EndPoint="0.682,0.629" StartPoint="0.251,0.072">
                            <GradientStop Color="#FF005C29" Offset="0"/>
                            <GradientStop Color="#FF37CE5D" Offset="1"/>
                        </LinearGradientBrush>
                    </Rectangle.Fill>
                </Rectangle>
                <Rectangle Margin="0,6.028,0,3.237" VerticalAlignment="Stretch" Stroke="{x:Null}" StrokeThickness="1.5" HorizontalAlignment="Right" Width="4">
                    <Rectangle.Fill>
                        <LinearGradientBrush EndPoint="0.682,0.629" StartPoint="0.251,0.072">
                            <GradientStop Color="#FF245D8E" Offset="0"/>
                            <GradientStop Color="#FF7CBBF0" Offset="1"/>
                        </LinearGradientBrush>
                    </Rectangle.Fill>
                </Rectangle>
                <Path Fill="#FF0E3245" Margin="0,0,8.393,2.502" Stretch="Fill" Stroke="{x:Null}" Data="M17.055993,2.8612035 C17.01432,2.8195397 6.4875335,3.0084335 6.0383376,11.501014 L2.4724872,11.393348 7.5385552,18.666928 13.91448,12.125937 9.8927639,11.721022 C8.4733861,5.0378628 17.055993,2.8616999 17.055993,2.8612035 z" HorizontalAlignment="Stretch"/>
            </Grid>
        </DataTemplate>
        <DataTemplate x:Key="DetailsTemplate">
            <TextBlock MaxHeight="15" Text="{Binding Path=Description}" ToolTip="{Binding Path=Description}" TextTrimming="CharacterEllipsis"></TextBlock>
        </DataTemplate>
    </UserControl.Resources>
    <Grid MaxHeight="220" ContextMenuOpening="ContextMenu_ContextMenuOpening">
        <Controls:SortListView PreviewKeyDown="DisplayListView_PreviewKeyDown" PreviewMouseDoubleClick="DisplayListView_PreviewMouseDoubleClick"  Style="{DynamicResource ListViewStyle2}" ItemsSource="{Binding Path=Items}" ScrollViewer.CanContentScroll="True" x:Name="DisplayListView" IsSynchronizedWithCurrentItem="True" ItemTemplate="{DynamicResource ParentDataTemplate}">
            <Controls:SortListView.ItemContainerStyle>
                <Style TargetType="{x:Type ListViewItem}">
                    <Setter Property="ContextMenu" Value="{StaticResource EmptyContextMenu}"/>
                    <Setter Property="Template" Value="{DynamicResource ListViewItemControlTemplate1}"/>
                    <EventSetter Event="ContextMenuOpening" Handler="ContextMenu_ContextMenuOpening"></EventSetter>
                    <!--<EventSetter Event="PreviewMouseDoubleClick" Handler="ListViewItemDoubleClicked"></EventSetter>-->
                </Style>
            </Controls:SortListView.ItemContainerStyle>
            <Controls:SortListView.View>
                <GridView>
                    <Controls:SortListViewColumn MinimumWidth="130" SortProperty="JobName" Width="150" Header="Job Name" DisplayMemberBinding="{Binding Path=JobName}"/>
                    <Controls:SortListViewColumn MinimumWidth="100" SortProperty="ScheduledBy" Width="130" Header="Schedule By" DisplayMemberBinding="{Binding Path=ScheduledBy}" />
                    <Controls:SortListViewColumn MinimumWidth="140" SortProperty="StartTime" Width="140" Header="Date Started" DisplayMemberBinding="{Binding Path=StartTime, Converter={StaticResource DateTimeConverter}}" />
                    <Controls:SortListViewColumn MinimumWidth="140" SortByDefault="True" DefaultSortDirection="Descending" SortProperty="CompletedTime" Width="140" Header="Date Completed" DisplayMemberBinding="{Binding Path=CompletedTime, Converter={StaticResource DateTimeConverter}}" />
                    <Controls:SortListViewColumn MinimumWidth="120" SortProperty="Status" Width="120" Header="Status" DisplayMemberBinding="{Binding Path=Status}" />
                    <Controls:SortListViewColumn MinimumWidth="200" Header="Result" CellTemplate="{StaticResource DetailsTemplate}"/>
                    <Controls:SortListViewColumn MinimumWidth="70" Width="70" Header="Provenance" CellTemplate="{StaticResource ProvenanceLink}"/>
                </GridView>
            </Controls:SortListView.View>

        </Controls:SortListView>
        <Grid Background="White" IsHitTestVisible="False" Visibility="{Binding Converter={StaticResource VisibilityConverter}, Path=EmptyList}" Width="{Binding Path=Width, ElementName=ListviewHost}" Height="{Binding Path=Height, ElementName=ListviewHost}">
            <TextBlock HorizontalAlignment="Center" Foreground="Gray">No Jobs of the selected workflow have been executed.</TextBlock>
        </Grid>
    </Grid>
</UserControl>
